/*
package com.zcah.sensitive.scan;


import com.zcah.sensitive.entity.HiveMeta;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Date;
import java.util.List;
import java.util.Map;

@Component
public class HiveScan {
    @Autowired
    @Qualifier("hiveTemplate")
    private JdbcTemplate jdbcTemplate;


    FileOutputStream o;

    public HiveScan(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    //@Scheduled(fixedRate = 60 * 5000)
    public String getDb_id() {
        Map<String, Object> map = this.jdbcTemplate.queryForMap("select * from user;");
        System.out.println(map.size());
        return "aa";
    }




    public void Fileout() throws IOException {
        File file = new File("E://out.txt");
        if (!file.exists()) {
            file.createNewFile();
        }
        o = new FileOutputStream(file);
    }
    */
/*@Scheduled(fixedRate = 5000)
    public String getDb_id() {
        Map<String, Object> map = this.jdbcTemplate.queryForMap("select * from user;");
        System.out.println(map.size());
        return "aa";
    }*//*


    public void getTBL_IDList() throws IOException {

        //从TBLS表中获取所有表的ID
        List<T_List> t_lists = jdbcTemplate.query("select TBL_ID from TBLS", new  TListRowMapper());
        for (T_List i : t_lists)
            System.out.println("***************" + i.getid());

        //遍历所有表
        Fileout();
        for (T_List til : t_lists) {
            HiveMeta hive = new HiveMeta();

            //设置tbl_id
            hive.settbl_id(til.getid());

            //设置db_id
            String sql0 = "select DB_ID from TBLS where TBL_ID=" + "'" + hive.gettbl_id() + "'";
            hive.setdb_id(jdbcTemplate.queryForObject(sql0, int.class));

            //设置db_name
            String sql1 = "select NAME from DBS where DB_ID=" + "'" + hive.getdb_id() + "'";
            hive.setdb_name((String) jdbcTemplate.queryForObject(sql1, String.class));

            //设置table_name
            String sql2 = "select TBL_NAME from TBLS where TBL_ID=" + "'" + hive.gettbl_id() + "'";
            hive.settable_name(jdbcTemplate.queryForObject(sql2, String.class));

            //设置create_time
            String sql3 = "select CREATE_TIME from TBLS where TBL_ID= " + "'" + hive.gettbl_id() + "'";
            hive.setcreate_time(jdbcTemplate.queryForObject(sql3, Date.class));

            //设置owner_name
            String sql4 = "select OWNER from TBLS where TBL_ID=" + "'" + hive.gettbl_id() + "'";
            hive.setowner_name(jdbcTemplate.queryForObject(sql4, String.class));

            //设置owner_type
            //String sql5 = "select ROLE_NAME from ROLES where ROLE_NAM=" + "'" +hive.getowner_name() + "'";
            //hive.setowner_type(jdbcTemplate.queryForObject(sql5, String.class));

            //设置hdfs_location_path
            String sql6 = "select SD_ID from TBLS where TBL_ID=" + "'" + hive.gettbl_id() + "'";
            int SD_ID = jdbcTemplate.queryForObject(sql6, int.class);
            String sql60 = "select LOCATION from SDS where SD_ID =" + "'" + SD_ID + "'";
            hive.sethdfs_location_path(jdbcTemplate.queryForObject(sql60, String.class));

            //设置column_names
            String sql7 = "select CD_ID from SDS where SD_ID=" + "'" + SD_ID + "'";
            int CD_ID = jdbcTemplate.queryForObject(sql7, Integer.class);
            String sql70 = "select COLUMN_NAME from COLUMNS_V2 where CD_ID=" + "'" + CD_ID + "'";
            List<Col_List> colname_list = jdbcTemplate.query(sql70, new ColListRowMapper());
            StringBuilder column = new StringBuilder();
            for (Col_List cnl : colname_list) {
                column.append(cnl.getCol_name())
                        .append(",");
            }
            hive.setcolumn_names(column.toString());

            //设置numfiles
            String sql8 = "";

            //设置gettotalsize

            //设置Found_datatime
            Long datenow = new java.util.Date().getTime();
            hive.setFound_datatime(new Date(datenow));

           */
/* System.out.println(hive.gettbl_id()+ "|"
                    +hive.getdb_id()+"|"
                    +hive.getdb_name()+"|"
                    +hive.gettable_name()+"|"
                    +hive.getcreate_time()+"|"
                    +hive.getowner_name()+"|"
                    +hive.getowner_type()+"|"
                    +hive.gethdfs_location_path() + "|"
                    +hive.getcolumn_names()+"|"
                    +hive.getFound_datatime()+"|");*//*

            String temp = hive.gettbl_id() + "|"
                    + hive.getdb_id() + "|"
                    + hive.getdb_name() + "|"
                    + hive.gettable_name() + "|"
                    + hive.getcreate_time() + "|"
                    + hive.getowner_name() + "|"
                    + hive.getowner_type() + "|"
                    + hive.gethdfs_location_path() + "|"
                    + hive.getcolumn_names() + "|"
                    + hive.getFound_datatime() + "|";
            o.write(temp.getBytes("GBK"));
        }
        o.close();
    }
}
*/
